﻿<Window
    x:Class="Trentacular.SharePoint.Deployment.Main"
    Title="SharePoint Solution Deployment Tool" Height="750" Width="1000"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sp="clr-namespace:Microsoft.SharePoint;assembly=Microsoft.SharePoint"
    xmlns:spa="clr-namespace:Microsoft.SharePoint.Administration;assembly=Microsoft.SharePoint"
    xmlns:local="clr-namespace:Trentacular.SharePoint.Deployment"
    xmlns:m="clr-namespace:Trentacular.SharePoint.Deployment.Model"
    xmlns:d="clr-namespace:Trentacular.SharePoint.Deployment.Data"
    xmlns:c="clr-namespace:Trentacular.SharePoint.Deployment.Converters"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <Window.Resources>
        
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0">
            <MenuItem Header="_File">
                <MenuItem Header="E_xit" Click="exitMenuItem_Click" />
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="_About SharePoint Solution Deployment Tool" Click="aboutMenuItem_Click" />
            </MenuItem>
        </Menu>
        <TabControl Grid.Row="1">
            <TabItem Header="Solutions Explorer">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="300" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <TreeView x:Name="solutionsTreeView"
                              Grid.Row="0"
                              Grid.Column="0"
                              DataContext="{Binding Path=SolutionsExplorer}"
                              ItemsSource="{Binding Path=Root}"
                              Loaded="solutionsTreeView_Loaded">
                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding Path=Solutions}">
                                <TextBlock Text="Installed Solutions" />
                                <HierarchicalDataTemplate.ItemTemplate>
                                    <HierarchicalDataTemplate ItemsSource="{Binding Path=Scopes}">
                                        <TextBlock Text="{Binding Path=Solution.DisplayName}" />
                                        <HierarchicalDataTemplate.ItemTemplate>
                                            <HierarchicalDataTemplate ItemsSource="{Binding Path=FeatureDefinitions}">
                                                <TextBlock Text="{Binding Path=DisplayName}" />
                                                <HierarchicalDataTemplate.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding Path=FeatureDefinition.DisplayName}" />
                                                    </DataTemplate>
                                                </HierarchicalDataTemplate.ItemTemplate>
                                            </HierarchicalDataTemplate>
                                        </HierarchicalDataTemplate.ItemTemplate>
                                    </HierarchicalDataTemplate>
                                </HierarchicalDataTemplate.ItemTemplate>
                            </HierarchicalDataTemplate>
                        </TreeView.ItemTemplate>
                    </TreeView>
                    <GridSplitter
                            ResizeDirection="Columns"
                            Width="3"
                            Height="Auto"
                            Margin="0" />
                    <Grid
                        Grid.Row="0"
                        Grid.Column="1"
                        DataContext="{Binding ElementName=solutionsTreeView, Path=SelectedItem}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Style="{StaticResource detailHeaderStyle}" Text="{Binding Path=DetailHeaderText}" />
                        <ListView Grid.Row="1" ItemsSource="{Binding Path=Solutions}">
                            <ListView.Style>
                                <Style TargetType="{x:Type ListView}">
                                    <Setter Property="Visibility" Value="Collapsed" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Path=Level}" Value="Root">
                                            <Setter Property="Visibility" Value="Visible" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </ListView.Style>
                            <ListView.View>
                                <GridView AllowsColumnReorder="True">
                                    <GridViewColumn Header="Name">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=Solution.DisplayName}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="ID">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=Solution.Id}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="Deployment State">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=Solution.DeploymentState}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="CAS Policy?">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=Solution.ContainsCasPolicy}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="Global Assembly?">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=Solution.ContainsGlobalAssembly}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="Web Application Resources?">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=Solution.ContainsWebApplicationResource}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                        <ListView Grid.Row="1" ItemsSource="{Binding Path=FeatureDefinitions}">
                            <ListView.Style>
                                <Style TargetType="{x:Type ListView}">
                                    <Setter Property="Visibility" Value="Collapsed" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Path=Level}" Value="Solution">
                                            <Setter Property="Visibility" Value="Visible" />
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Path=Level}" Value="Scope">
                                            <Setter Property="Visibility" Value="Visible" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </ListView.Style>
                            <ListView.View>
                                <GridView AllowsColumnReorder="True">
                                    <GridViewColumn Header="Name">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=FeatureDefinition.DisplayName}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="ID">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=FeatureDefinition.Id}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="Title">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=FeatureDefinition.Title}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="Scope">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=Parent.DisplayName}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="Description">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=FeatureDefinition.Description}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                        
                        <ListView Grid.Row="1" ItemsSource="{Binding Path=ActivatedFeatures}">
                            <ListView.Style>
                                <Style TargetType="{x:Type ListView}">
                                    <Setter Property="Visibility" Value="Collapsed" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Path=Level}" Value="FeatureDefinition">
                                            <Setter Property="Visibility" Value="Visible" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </ListView.Style>
                            <ListView.View>
                                <GridView AllowsColumnReorder="True">
                                    <GridViewColumn Header="Parent">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=Parent}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn> 
                                    <GridViewColumn Header="Activated?">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBox Text="{Binding Path=Activated}" Style="{StaticResource cellValueStyle}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </Grid>
                </Grid>
            </TabItem>
        </TabControl>
        <StatusBar Grid.Row="2" Height="20">
            <ProgressBar Width="80" Height="14" IsIndeterminate="{Binding Path=IsDoingWork}" />
            <TextBlock Width="100">
                <TextBlock.Style>
                    <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="Text" Value="Ready" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=IsDoingWork}" Value="True">
                                <Setter Property="Text" Value="Loading ..." />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
        </StatusBar>
    </Grid>
</Window>
